# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>

_realname=rpyc
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=5.0.1
pkgrel=2
pkgdesc='Remote Python Call - A transparent and symmetric RPC library for python (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/tomerfiliba-org/rpyc"
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python-plumbum")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=("https://github.com/tomerfiliba-org/rpyc/archive/${pkgver}.tar.gz")
sha256sums=('581f14e49781242c34b55f989bec24dd386ff0d5d445b8d972c7e52bd3219112')

export PYTHONHASHSEED=0

prepare() {  
  cd "$srcdir"
  rm -rf python-build-${CARCH} | true
  cp -r "${_realname}-$pkgver" "python-build-${CARCH}"
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  sed -e '1 { s/^#!.*$// }' -i "${pkgdir}${MINGW_PREFIX}/bin/rpyc_classic.py"
  sed -e '1 { s/^#!.*$// }' -i "${pkgdir}${MINGW_PREFIX}/bin/rpyc_registry.py"
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
